# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mc
pkgver=4.8.25
pkgrel=0
pkgdesc="Filemanager/shell that emulates Norton Commander"
url="https://www.midnight-commander.org"
arch="all"
license="GPL-3.0-or-later"
subpackages="$pkgname-doc $pkgname-lang"
makedepends="e2fsprogs-dev glib-dev libssh2-dev ncurses-dev perl"
source="https://www.midnight-commander.org/downloads/mc-$pkgver.tar.xz
	alpine_syntax.patch"


build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--mandir=/usr/share/man \
		--sysconfdir=/etc \
		--enable-background \
		--enable-charset \
		--enable-largefile \
		--enable-vfs-sftp \
		--with-internal-edit \
		--with-mmap \
		--with-screen=ncurses \
		--with-subshell \
		--without-gpm-mouse \
		--without-included-gettext \
		--without-x
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -fr "$pkgdir"/usr/share/man/??
}

doc() {
	default_doc
	mkdir -p "$subpkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/mc/examples \
		"$subpkgdir"/usr/share/doc/mc
	find "$pkgdir"/usr/lib/mc -name "README*" \
		-exec mv {} "$subpkgdir"/usr/share/doc/mc/ \;
}

lang() {
	default_lang
	mkdir -p "$subpkgdir"/usr/share/mc/help \
		"$subpkgdir"/usr/share/mc/hints
	mv "$pkgdir"/usr/share/mc/help/mc.hlp.* \
		"$subpkgdir"/usr/share/mc/help/
	mv "$pkgdir"/usr/share/mc/hints/mc.hint.* \
		"$subpkgdir"/usr/share/mc/hints/
}

sha512sums="51913fd41df18b49498b97ad8e13aa4365cec24ab24169b1abe93209263e4cfea4b52e0faccaf934182c84e8eb5dc49336c885358b4b66c48d38900f890fde5e  mc-4.8.25.tar.xz
47aa001e8c20a24631617d665fd0d81b269ebad96696c4bd70c7040bbca713868e02fe53dfaee9a775a57f35a0e7c9e44ce299037379e249ad27354a78d905c3  alpine_syntax.patch"
